package com.hsgene.goods.condition;

import com.hsgene.common.util.support.OrderField;

import java.util.stream.Stream;

/**
 * 商城商品排序参数
 *
 * @author wangbing
 * @version 1.0, 2018/8/23
 */
public enum GoodsMallOrderField implements OrderField {

    /**
     * 创建时间
     */
    DEFAULT("createTime"),

    /**
     * 销量排序
     */
    SALES("sales"),

    /**
     * 价格排序
     */
    PRICE("price"),

    /**
     * 评论量排序
     */
    GOODS_COMMENT("comment");

    private final String value;

    public String getValue() {
        return value;
    }

    GoodsMallOrderField(String value) {
        this.value = value;
    }

    public static OrderField getInstance() {
        return values()[0];
    }

    @Override
    public Stream<String> getNames() {
        return Stream.of(values()).map(val -> val.getValue());
    }

    @Override
    public boolean check(String fieldName) {
        return OrderField.check(this, fieldName);
    }
}
